package com.stockz.downloader.util;

import java.util.List;

import com.stockz.downloader.Download;
import com.stockz.downloader.DownloaderCallback;

public final class DownloaderUtil {

	private DownloaderUtil() {
		// final class with private constructor thus singleton
	}
	
	public static <T extends Download<V>,V,W extends DownloaderCallback<T,V,U>,U> 
	void executeCallbacks(T download, 
			DownloaderConstant.ACTION action, DownloaderConstant.EVENT event,
			U customPayload, List<W> downloaderCallbackList){
		if(download != null && downloaderCallbackList != null && !downloaderCallbackList.isEmpty()){
			download.setAction(action);
			download.setEvent(event);
			for(W downloaderCallback : downloaderCallbackList){
				downloaderCallback.execute(download, customPayload);
			}
		}
	}
}
